<?php
/**
 * Created by PhpStorm.
 * User: Xwen
 * Date: 2018/12/9
 * Time: 14:34
 *
 *          ┌─┐       ┌─┐
 *       ┌──┘ ┴───────┘ ┴──┐
 *       │                 │
 *       │       ───       │
 *       │  ─┬┘       └┬─  │
 *       │                 │
 *       │       ─┴─       │
 *       │                 │
 *       └───┐         ┌───┘
 *           │         │
 *           │         │
 *           │         │
 *           │         └──────────────┐
 *           │                        │
 *           │                        ├─┐
 *           │                        ┌─┘
 *           │                        │
 *           └─┐  ┐  ┌───────┬──┐  ┌──┘
 *             │ ─┤ ─┤       │ ─┤ ─┤
 *             └──┴──┘       └──┴──┘
 *                 神兽保佑
 *                 代码无BUG!
 *"The trouble with programmers is that you can never tell what a programmer is doing until it’s too late.”- Seymour Cray
 */
namespace app\admin\model;

use think\Exception;
use think\Model;

class User extends Model
{
    public function getOneById($id){
        return $this->where('is_delete', 0)->where('id', $id)->find();
    }
    public function getPage($where, $pageNumber, $pageSize){
        $data = $this->where($where)->limit($pageNumber, $pageSize)->select();
        return $data ? $data :false;
    }
    public function getCount($where){
        $count = $this->where($where)->count();
        return $count ? $count :false;
    }
    public function updateOne($where, $data){
        return $this->where($where)->update($data);
    }
    public function login($where){
        $res = $this->where($where)->field('id')->find();
        return $res ? $res : false;
    }
}